package spring;

import org.springframework.core.env.AbstractEnvironment;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import spring.jdbc.config.RootConfig;
import spring.jdbc.config.WebConfig;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;

/**
 * Created by kassadin@foxmail.com on 2017/4/28 0028.
 */
public class App extends AbstractAnnotationConfigDispatcherServletInitializer {
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{RootConfig.class};
    }

    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{WebConfig.class};
    }

    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    // http://www.mkyong.com/spring-mvc/spring-mvc-how-to-set-active-profile/
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        super.onStartup(servletContext);
        // profile
        servletContext.setInitParameter(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "dev");
    }
}
